<?php


abstract class BaseUsuario extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $nombre;


	
	protected $pass_md5;


	
	protected $email;


	
	protected $mostrar_correo;


	
	protected $codigo_verificacion;


	
	protected $privilegios = 2;


	
	protected $ciudad;


	
	protected $pais;


	
	protected $permite_intercambio;

	
	protected $collNoticias;

	
	protected $lastNoticiaCriteria = null;

	
	protected $collPeticions;

	
	protected $lastPeticionCriteria = null;

	
	protected $collValoracionXVideos;

	
	protected $lastValoracionXVideoCriteria = null;

	
	protected $collVideos;

	
	protected $lastVideoCriteria = null;

	
	protected $collVideoXUsuarios;

	
	protected $lastVideoXUsuarioCriteria = null;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getNombre()
	{

		return $this->nombre;
	}

	
	public function getPassMd5()
	{

		return $this->pass_md5;
	}

	
	public function getEmail()
	{

		return $this->email;
	}

	
	public function getMostrarCorreo()
	{

		return $this->mostrar_correo;
	}

	
	public function getCodigoVerificacion()
	{

		return $this->codigo_verificacion;
	}

	
	public function getPrivilegios()
	{

		return $this->privilegios;
	}

	
	public function getCiudad()
	{

		return $this->ciudad;
	}

	
	public function getPais()
	{

		return $this->pais;
	}

	
	public function getPermiteIntercambio()
	{

		return $this->permite_intercambio;
	}

	
	public function setId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = UsuarioPeer::ID;
		}

	} 
	
	public function setNombre($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->nombre !== $v) {
			$this->nombre = $v;
			$this->modifiedColumns[] = UsuarioPeer::NOMBRE;
		}

	} 
	
	public function setPassMd5($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->pass_md5 !== $v) {
			$this->pass_md5 = $v;
			$this->modifiedColumns[] = UsuarioPeer::PASS_MD5;
		}

	} 
	
	public function setEmail($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->email !== $v) {
			$this->email = $v;
			$this->modifiedColumns[] = UsuarioPeer::EMAIL;
		}

	} 
	
	public function setMostrarCorreo($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->mostrar_correo !== $v) {
			$this->mostrar_correo = $v;
			$this->modifiedColumns[] = UsuarioPeer::MOSTRAR_CORREO;
		}

	} 
	
	public function setCodigoVerificacion($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->codigo_verificacion !== $v) {
			$this->codigo_verificacion = $v;
			$this->modifiedColumns[] = UsuarioPeer::CODIGO_VERIFICACION;
		}

	} 
	
	public function setPrivilegios($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->privilegios !== $v || $v === 2) {
			$this->privilegios = $v;
			$this->modifiedColumns[] = UsuarioPeer::PRIVILEGIOS;
		}

	} 
	
	public function setCiudad($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->ciudad !== $v) {
			$this->ciudad = $v;
			$this->modifiedColumns[] = UsuarioPeer::CIUDAD;
		}

	} 
	
	public function setPais($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->pais !== $v) {
			$this->pais = $v;
			$this->modifiedColumns[] = UsuarioPeer::PAIS;
		}

	} 
	
	public function setPermiteIntercambio($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->permite_intercambio !== $v) {
			$this->permite_intercambio = $v;
			$this->modifiedColumns[] = UsuarioPeer::PERMITE_INTERCAMBIO;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->nombre = $rs->getString($startcol + 1);

			$this->pass_md5 = $rs->getString($startcol + 2);

			$this->email = $rs->getString($startcol + 3);

			$this->mostrar_correo = $rs->getInt($startcol + 4);

			$this->codigo_verificacion = $rs->getString($startcol + 5);

			$this->privilegios = $rs->getInt($startcol + 6);

			$this->ciudad = $rs->getString($startcol + 7);

			$this->pais = $rs->getString($startcol + 8);

			$this->permite_intercambio = $rs->getInt($startcol + 9);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 10; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Usuario object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(UsuarioPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			UsuarioPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(UsuarioPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = UsuarioPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += UsuarioPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			if ($this->collNoticias !== null) {
				foreach($this->collNoticias as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			if ($this->collPeticions !== null) {
				foreach($this->collPeticions as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			if ($this->collValoracionXVideos !== null) {
				foreach($this->collValoracionXVideos as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			if ($this->collVideos !== null) {
				foreach($this->collVideos as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			if ($this->collVideoXUsuarios !== null) {
				foreach($this->collVideoXUsuarios as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = UsuarioPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}


				if ($this->collNoticias !== null) {
					foreach($this->collNoticias as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}

				if ($this->collPeticions !== null) {
					foreach($this->collPeticions as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}

				if ($this->collValoracionXVideos !== null) {
					foreach($this->collValoracionXVideos as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}

				if ($this->collVideos !== null) {
					foreach($this->collVideos as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}

				if ($this->collVideoXUsuarios !== null) {
					foreach($this->collVideoXUsuarios as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}


			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = UsuarioPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getNombre();
				break;
			case 2:
				return $this->getPassMd5();
				break;
			case 3:
				return $this->getEmail();
				break;
			case 4:
				return $this->getMostrarCorreo();
				break;
			case 5:
				return $this->getCodigoVerificacion();
				break;
			case 6:
				return $this->getPrivilegios();
				break;
			case 7:
				return $this->getCiudad();
				break;
			case 8:
				return $this->getPais();
				break;
			case 9:
				return $this->getPermiteIntercambio();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = UsuarioPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getNombre(),
			$keys[2] => $this->getPassMd5(),
			$keys[3] => $this->getEmail(),
			$keys[4] => $this->getMostrarCorreo(),
			$keys[5] => $this->getCodigoVerificacion(),
			$keys[6] => $this->getPrivilegios(),
			$keys[7] => $this->getCiudad(),
			$keys[8] => $this->getPais(),
			$keys[9] => $this->getPermiteIntercambio(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = UsuarioPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setNombre($value);
				break;
			case 2:
				$this->setPassMd5($value);
				break;
			case 3:
				$this->setEmail($value);
				break;
			case 4:
				$this->setMostrarCorreo($value);
				break;
			case 5:
				$this->setCodigoVerificacion($value);
				break;
			case 6:
				$this->setPrivilegios($value);
				break;
			case 7:
				$this->setCiudad($value);
				break;
			case 8:
				$this->setPais($value);
				break;
			case 9:
				$this->setPermiteIntercambio($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = UsuarioPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setNombre($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setPassMd5($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setEmail($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setMostrarCorreo($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setCodigoVerificacion($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setPrivilegios($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setCiudad($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setPais($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setPermiteIntercambio($arr[$keys[9]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(UsuarioPeer::DATABASE_NAME);

		if ($this->isColumnModified(UsuarioPeer::ID)) $criteria->add(UsuarioPeer::ID, $this->id);
		if ($this->isColumnModified(UsuarioPeer::NOMBRE)) $criteria->add(UsuarioPeer::NOMBRE, $this->nombre);
		if ($this->isColumnModified(UsuarioPeer::PASS_MD5)) $criteria->add(UsuarioPeer::PASS_MD5, $this->pass_md5);
		if ($this->isColumnModified(UsuarioPeer::EMAIL)) $criteria->add(UsuarioPeer::EMAIL, $this->email);
		if ($this->isColumnModified(UsuarioPeer::MOSTRAR_CORREO)) $criteria->add(UsuarioPeer::MOSTRAR_CORREO, $this->mostrar_correo);
		if ($this->isColumnModified(UsuarioPeer::CODIGO_VERIFICACION)) $criteria->add(UsuarioPeer::CODIGO_VERIFICACION, $this->codigo_verificacion);
		if ($this->isColumnModified(UsuarioPeer::PRIVILEGIOS)) $criteria->add(UsuarioPeer::PRIVILEGIOS, $this->privilegios);
		if ($this->isColumnModified(UsuarioPeer::CIUDAD)) $criteria->add(UsuarioPeer::CIUDAD, $this->ciudad);
		if ($this->isColumnModified(UsuarioPeer::PAIS)) $criteria->add(UsuarioPeer::PAIS, $this->pais);
		if ($this->isColumnModified(UsuarioPeer::PERMITE_INTERCAMBIO)) $criteria->add(UsuarioPeer::PERMITE_INTERCAMBIO, $this->permite_intercambio);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(UsuarioPeer::DATABASE_NAME);

		$criteria->add(UsuarioPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setNombre($this->nombre);

		$copyObj->setPassMd5($this->pass_md5);

		$copyObj->setEmail($this->email);

		$copyObj->setMostrarCorreo($this->mostrar_correo);

		$copyObj->setCodigoVerificacion($this->codigo_verificacion);

		$copyObj->setPrivilegios($this->privilegios);

		$copyObj->setCiudad($this->ciudad);

		$copyObj->setPais($this->pais);

		$copyObj->setPermiteIntercambio($this->permite_intercambio);


		if ($deepCopy) {
									$copyObj->setNew(false);

			foreach($this->getNoticias() as $relObj) {
				$copyObj->addNoticia($relObj->copy($deepCopy));
			}

			foreach($this->getPeticions() as $relObj) {
				$copyObj->addPeticion($relObj->copy($deepCopy));
			}

			foreach($this->getValoracionXVideos() as $relObj) {
				$copyObj->addValoracionXVideo($relObj->copy($deepCopy));
			}

			foreach($this->getVideos() as $relObj) {
				$copyObj->addVideo($relObj->copy($deepCopy));
			}

			foreach($this->getVideoXUsuarios() as $relObj) {
				$copyObj->addVideoXUsuario($relObj->copy($deepCopy));
			}

		} 

		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new UsuarioPeer();
		}
		return self::$peer;
	}

	
	public function initNoticias()
	{
		if ($this->collNoticias === null) {
			$this->collNoticias = array();
		}
	}

	
	public function getNoticias($criteria = null, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collNoticias === null) {
			if ($this->isNew()) {
			   $this->collNoticias = array();
			} else {

				$criteria->add(NoticiaPeer::USUARIO_ID, $this->getId());

				NoticiaPeer::addSelectColumns($criteria);
				$this->collNoticias = NoticiaPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(NoticiaPeer::USUARIO_ID, $this->getId());

				NoticiaPeer::addSelectColumns($criteria);
				if (!isset($this->lastNoticiaCriteria) || !$this->lastNoticiaCriteria->equals($criteria)) {
					$this->collNoticias = NoticiaPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastNoticiaCriteria = $criteria;
		return $this->collNoticias;
	}

	
	public function countNoticias($criteria = null, $distinct = false, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(NoticiaPeer::USUARIO_ID, $this->getId());

		return NoticiaPeer::doCount($criteria, $distinct, $con);
	}

	
	public function addNoticia(Noticia $l)
	{
		$this->collNoticias[] = $l;
		$l->setUsuario($this);
	}

	
	public function initPeticions()
	{
		if ($this->collPeticions === null) {
			$this->collPeticions = array();
		}
	}

	
	public function getPeticions($criteria = null, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collPeticions === null) {
			if ($this->isNew()) {
			   $this->collPeticions = array();
			} else {

				$criteria->add(PeticionPeer::USUARIO_ID, $this->getId());

				PeticionPeer::addSelectColumns($criteria);
				$this->collPeticions = PeticionPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(PeticionPeer::USUARIO_ID, $this->getId());

				PeticionPeer::addSelectColumns($criteria);
				if (!isset($this->lastPeticionCriteria) || !$this->lastPeticionCriteria->equals($criteria)) {
					$this->collPeticions = PeticionPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastPeticionCriteria = $criteria;
		return $this->collPeticions;
	}

	
	public function countPeticions($criteria = null, $distinct = false, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(PeticionPeer::USUARIO_ID, $this->getId());

		return PeticionPeer::doCount($criteria, $distinct, $con);
	}

	
	public function addPeticion(Peticion $l)
	{
		$this->collPeticions[] = $l;
		$l->setUsuario($this);
	}


	
	public function getPeticionsJoinPrioridad($criteria = null, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collPeticions === null) {
			if ($this->isNew()) {
				$this->collPeticions = array();
			} else {

				$criteria->add(PeticionPeer::USUARIO_ID, $this->getId());

				$this->collPeticions = PeticionPeer::doSelectJoinPrioridad($criteria, $con);
			}
		} else {
									
			$criteria->add(PeticionPeer::USUARIO_ID, $this->getId());

			if (!isset($this->lastPeticionCriteria) || !$this->lastPeticionCriteria->equals($criteria)) {
				$this->collPeticions = PeticionPeer::doSelectJoinPrioridad($criteria, $con);
			}
		}
		$this->lastPeticionCriteria = $criteria;

		return $this->collPeticions;
	}


	
	public function getPeticionsJoinSeccion($criteria = null, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collPeticions === null) {
			if ($this->isNew()) {
				$this->collPeticions = array();
			} else {

				$criteria->add(PeticionPeer::USUARIO_ID, $this->getId());

				$this->collPeticions = PeticionPeer::doSelectJoinSeccion($criteria, $con);
			}
		} else {
									
			$criteria->add(PeticionPeer::USUARIO_ID, $this->getId());

			if (!isset($this->lastPeticionCriteria) || !$this->lastPeticionCriteria->equals($criteria)) {
				$this->collPeticions = PeticionPeer::doSelectJoinSeccion($criteria, $con);
			}
		}
		$this->lastPeticionCriteria = $criteria;

		return $this->collPeticions;
	}

	
	public function initValoracionXVideos()
	{
		if ($this->collValoracionXVideos === null) {
			$this->collValoracionXVideos = array();
		}
	}

	
	public function getValoracionXVideos($criteria = null, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collValoracionXVideos === null) {
			if ($this->isNew()) {
			   $this->collValoracionXVideos = array();
			} else {

				$criteria->add(ValoracionXVideoPeer::USUARIO_ID, $this->getId());

				ValoracionXVideoPeer::addSelectColumns($criteria);
				$this->collValoracionXVideos = ValoracionXVideoPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(ValoracionXVideoPeer::USUARIO_ID, $this->getId());

				ValoracionXVideoPeer::addSelectColumns($criteria);
				if (!isset($this->lastValoracionXVideoCriteria) || !$this->lastValoracionXVideoCriteria->equals($criteria)) {
					$this->collValoracionXVideos = ValoracionXVideoPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastValoracionXVideoCriteria = $criteria;
		return $this->collValoracionXVideos;
	}

	
	public function countValoracionXVideos($criteria = null, $distinct = false, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(ValoracionXVideoPeer::USUARIO_ID, $this->getId());

		return ValoracionXVideoPeer::doCount($criteria, $distinct, $con);
	}

	
	public function addValoracionXVideo(ValoracionXVideo $l)
	{
		$this->collValoracionXVideos[] = $l;
		$l->setUsuario($this);
	}


	
	public function getValoracionXVideosJoinVideo($criteria = null, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collValoracionXVideos === null) {
			if ($this->isNew()) {
				$this->collValoracionXVideos = array();
			} else {

				$criteria->add(ValoracionXVideoPeer::USUARIO_ID, $this->getId());

				$this->collValoracionXVideos = ValoracionXVideoPeer::doSelectJoinVideo($criteria, $con);
			}
		} else {
									
			$criteria->add(ValoracionXVideoPeer::USUARIO_ID, $this->getId());

			if (!isset($this->lastValoracionXVideoCriteria) || !$this->lastValoracionXVideoCriteria->equals($criteria)) {
				$this->collValoracionXVideos = ValoracionXVideoPeer::doSelectJoinVideo($criteria, $con);
			}
		}
		$this->lastValoracionXVideoCriteria = $criteria;

		return $this->collValoracionXVideos;
	}

	
	public function initVideos()
	{
		if ($this->collVideos === null) {
			$this->collVideos = array();
		}
	}

	
	public function getVideos($criteria = null, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collVideos === null) {
			if ($this->isNew()) {
			   $this->collVideos = array();
			} else {

				$criteria->add(VideoPeer::USUARIO_ID, $this->getId());

				VideoPeer::addSelectColumns($criteria);
				$this->collVideos = VideoPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(VideoPeer::USUARIO_ID, $this->getId());

				VideoPeer::addSelectColumns($criteria);
				if (!isset($this->lastVideoCriteria) || !$this->lastVideoCriteria->equals($criteria)) {
					$this->collVideos = VideoPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastVideoCriteria = $criteria;
		return $this->collVideos;
	}

	
	public function countVideos($criteria = null, $distinct = false, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(VideoPeer::USUARIO_ID, $this->getId());

		return VideoPeer::doCount($criteria, $distinct, $con);
	}

	
	public function addVideo(Video $l)
	{
		$this->collVideos[] = $l;
		$l->setUsuario($this);
	}


	
	public function getVideosJoinTipoDescarga($criteria = null, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collVideos === null) {
			if ($this->isNew()) {
				$this->collVideos = array();
			} else {

				$criteria->add(VideoPeer::USUARIO_ID, $this->getId());

				$this->collVideos = VideoPeer::doSelectJoinTipoDescarga($criteria, $con);
			}
		} else {
									
			$criteria->add(VideoPeer::USUARIO_ID, $this->getId());

			if (!isset($this->lastVideoCriteria) || !$this->lastVideoCriteria->equals($criteria)) {
				$this->collVideos = VideoPeer::doSelectJoinTipoDescarga($criteria, $con);
			}
		}
		$this->lastVideoCriteria = $criteria;

		return $this->collVideos;
	}

	
	public function initVideoXUsuarios()
	{
		if ($this->collVideoXUsuarios === null) {
			$this->collVideoXUsuarios = array();
		}
	}

	
	public function getVideoXUsuarios($criteria = null, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collVideoXUsuarios === null) {
			if ($this->isNew()) {
			   $this->collVideoXUsuarios = array();
			} else {

				$criteria->add(VideoXUsuarioPeer::USUARIO_ID, $this->getId());

				VideoXUsuarioPeer::addSelectColumns($criteria);
				$this->collVideoXUsuarios = VideoXUsuarioPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(VideoXUsuarioPeer::USUARIO_ID, $this->getId());

				VideoXUsuarioPeer::addSelectColumns($criteria);
				if (!isset($this->lastVideoXUsuarioCriteria) || !$this->lastVideoXUsuarioCriteria->equals($criteria)) {
					$this->collVideoXUsuarios = VideoXUsuarioPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastVideoXUsuarioCriteria = $criteria;
		return $this->collVideoXUsuarios;
	}

	
	public function countVideoXUsuarios($criteria = null, $distinct = false, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(VideoXUsuarioPeer::USUARIO_ID, $this->getId());

		return VideoXUsuarioPeer::doCount($criteria, $distinct, $con);
	}

	
	public function addVideoXUsuario(VideoXUsuario $l)
	{
		$this->collVideoXUsuarios[] = $l;
		$l->setUsuario($this);
	}


	
	public function getVideoXUsuariosJoinVideo($criteria = null, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collVideoXUsuarios === null) {
			if ($this->isNew()) {
				$this->collVideoXUsuarios = array();
			} else {

				$criteria->add(VideoXUsuarioPeer::USUARIO_ID, $this->getId());

				$this->collVideoXUsuarios = VideoXUsuarioPeer::doSelectJoinVideo($criteria, $con);
			}
		} else {
									
			$criteria->add(VideoXUsuarioPeer::USUARIO_ID, $this->getId());

			if (!isset($this->lastVideoXUsuarioCriteria) || !$this->lastVideoXUsuarioCriteria->equals($criteria)) {
				$this->collVideoXUsuarios = VideoXUsuarioPeer::doSelectJoinVideo($criteria, $con);
			}
		}
		$this->lastVideoXUsuarioCriteria = $criteria;

		return $this->collVideoXUsuarios;
	}

} 